package com.spider.controller;

import com.spider.entites.Menu;
import com.spider.mapper.MenuMapper;
import com.spider.service.MenuService;
import com.spider.vo.ResultVo;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 菜单提取
 * @author panglin
 * @date 2020/11/19 11:25
 */
@RestController
@RequestMapping("api")
public class MenuController {

    @Resource
    private MenuService menuService;

    @GetMapping("menus")
    public ResultVo menus(){
        List<Menu> menus = this.menuService.menus();
        if (CollectionUtils.isEmpty(menus)){
            return ResultVo.builder(404, "菜单为空");
        }else {
            return ResultVo.builder(200, "查询成功",menus);
        }
    }
}
